home *** CD-ROM | disk | FTP | other *** search
/ Fritz: All Fritz / All Fritz.zip / All Fritz / FILES / PROGNG_C / CFUNCTS.LZH / RND.C < prev    next >
Text File  |  1986-06-09  |  520b  |  33 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. main(nargs,arg)
  5. int nargs;
  6. char *arg[];
  7. {
  8.  int max;
  9.  int a;
  10.  int z;
  11.         if (nargs != 2)
  12.            printf("usage rnd(max no)\n");
  13.         else {
  14.         max = *arg[1] - '0';
  15.         printf("max = %d\n",max);
  16.         for (a = 0; a < 15; ++a) {
  17.                z = rnd(max);
  18.                printf("%d\n",z);
  19.                }
  20.         }
  21. }
  22.  
  23.  
  24.  
  25. rnd(lim)
  26. int lim;
  27. {
  28. int op;
  29. int no;
  30.        op = 32768/lim;
  31.        no = (rand()/op)+1;
  32.        return(no);
  33. }